<!-- Codes by Quackit.com -->
<script type="text/javascript">
// Popup window code
var timer;
var popupWindow;
function newPopup(url) {
	popupWindow = window.open(
		url,'popUpWindow','height=500,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes');
		
	timer = setInterval("update_after_change()", 100);
}

function update_after_change() {
       
   if(popupWindow.closed == true) 
   {
   		clearInterval(timer);
   		self.location.reload(); 
   		return;
   }
}

</script>

<?php
elgg_load_library('elgg:portfolio');

$usr_obj = elgg_get_logged_in_user_entity();
$usr_id = $usr_obj->username;

$today = last_working_day(strftime('%Y-%m-%d', time()));
$lastday = last_working_day(strftime('%Y-%m-%d', time()));
$date_param = get_param_value('date_param', 'trade_date_param', $lastday);
$date_param2 = get_param_value('date_param2', 'trade_date_param2', $today);
$fund_param = get_param_value('fund_param', 'trade_fund_param', 'ALL');
$securities_param = get_param_value('securities_param', 'trade_securities_param', '');

//print_r($securities_param);
//print_r($fund_param);
//print_r($date_param);
//print_r($date_param2);

$tableArray = portfolio_get_trade($date_param, $date_param2, $usr_id, $fund_param, $securities_param);
echo elgg_view('output/tablesorter', 
	array(
		'value' => $tableArray,
		'tableid' => 'trade'
	)
);
